package Tests;

import Others.*;
import MainMethods.*;

import java.io.IOException;
import java.util.Date;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;

import Tabs.PlayGames;
import Tabs.PlayMovie;
import Tabs.PlayMusic;
import Tabs.ReadBook;
import Tabs.Software;

public class Test {

	static LogIn logInOut = new LogIn();
	static Membership member = new Membership();
	static PlayMusic play = new PlayMusic();
	static ReadBook read = new ReadBook();
	static Software soft = new Software();
	static PlayGames game = new PlayGames();
	static PlayMovie movie = new PlayMovie();
	static Account account = new Account();
	static Search search = new Search();

	public void testSignUp(WebDriver driver, FileWr file, String screenDir)
			throws InterruptedException, IOException {
		driver.get("http://staging.pf-ayeplay.jomediainc.com/signup?sf=eight_r");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		file.writeFile("SIGN UP - STARTED");
		logInOut.signUp(driver, file, screenDir);
		file.writeFile("SIGN UP - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("LOG IN - STARTED");
		logInOut.login(driver, file);
		// logInOut.reserveLogin(driver, file, screenDir);
		file.writeFile("LOG IN - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("Membership upgrade - STARTED");
		member.getPremiumAccess(driver, file);
		file.writeFile("Membership upgrade - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
		
	}

	public void testMusic(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("MUSIC - STARTED");
		play.playAlbums(driver, file, screenDir);
		file.writeFile("MUSIC - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}

	public void testBooks(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("BOOKS - STARTED");
		read.readTest(driver, file, screenDir);
		file.writeFile("BOOKS - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}

	public void testMovies(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("MOVIES - STARTED");
		movie.movieTest(driver, file, screenDir);
		file.writeFile("MOVIES - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}

	public void testSoft(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("SOFTWARE - STARTED");
		soft.softwareTest(driver, file, screenDir);
		file.writeFile("CHECK SCREENSHOTS!!!!!!!!!!!!");
		file.writeFile("SOFTWARE - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}

	public void testAccount(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("ACCOUNT - STARTED");
		account.accountWorks(driver, file);
		file.writeFile("ACCOUNT - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}
	public void testCancelSearch(WebDriver driver, FileWr file, String screenDir)
			throws IOException, NoSuchElementException, InterruptedException {
		driver.get("http://staging.membersarea.jomediainc.com/#front/home");
		Date startDate = new Date();
		file.writeFile(startDate.toString());
		logInOut.login(driver, file);
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("CANCEL - STARTED");
		account.cancelMembership(driver, file, screenDir);
		file.writeFile("CANCEL - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		file.writeFile("SEARCH - STARTED");
		search.searchWork(driver, file, screenDir);
		file.writeFile("SEARCH - FINISHED");
		file.writeFile("-----------------------------------------------------------------------------");
		logInOut.logout(driver, file);
		Date endDate = new Date();
		file.writeFile(endDate.toString());
		file.closeWrite();
	}
}
